// 2025/3/25
// 数组中的最长连续子序列

class Solution {
    public:
        /**
         * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
         *
         * max increasing subsequence
         * @param arr int整型vector the array
         * @return int整型
         */
        int MLS(vector<int>& arr) {
            // write code here
            int n = arr.size();
            sort(arr.begin(), arr.end());
            int left = 0, right = 0;
            int ans = 1, count = 1;
            while(right < n)
            {
                if(right < n - 1 && arr[right + 1] == arr[right] + 1)
                    count++;
                else if(right >= n - 1 || arr[right + 1] != arr[right])
                {
                    ans = max(ans, count);
                    left = right + 1;
                    count = 1;
                }
                right++;
            }
            return ans;
        }
    };